export const columns = [
  { label: '', prop: 'index', width: '80px', type: 'index' },
  { label: '顾问姓名', prop: 'name', width: '120px' },
  { label: '联系电话', prop: 'phone', width: '120px' },
  {
    label: '性别',
    prop: 'sex',
    type: 'radio',
    options: [
      { label: '男', value: 1 },
      { label: '女', value: 0 },
    ],
    width: '120px',
  },
  {
    label: '角色类型',
    prop: 'userType',
    type: 'select',
    options: [
      { label: '管理员', value: 1 },
      { label: '销售', value: 2 },
      { label: '小区管理员', value: 3 },
    ],
    width: '120px',
    search: true,
  },
  { label: '服务年限', prop: 'serviceYears', width: '120px' },
  { label: '微信号', prop: 'wxId', width: '120px' },
  { label: '照片', prop: 'imageUrl', type: 'image', width: '120px' },
  { label: '操作', prop: 'action', slotName: 'action', width: '100px', fixed: 'right' },
]

export const formOptions = [
  { label: '姓名', prop: 'name', rules: [{ required: true, message: '请输入姓名', trigger: 'blur' }] },
  { label: '联系电话', prop: 'phone' },
  {
    label: '性别',
    prop: 'sex',
    type: 'radio',
    options: [
      { label: '男', value: 1 },
      { label: '女', value: 0 },
    ],
  },
  { label: '服务年限', prop: 'serviceYears', type: 'number', unit: '年' },
  { label: '微信号', prop: 'wxId' },
  {
    label: '角色类型',
    prop: 'userType',
    type: 'select',
    options: [
      { label: '管理员', value: 1 },
      { label: '销售', value: 2 },
      { label: '小区管理员', value: 3 },
    ],
    rules: [{ required: true, message: '请选择角色类型', trigger: 'change' }],
  },
  {
    label: '所属小区',
    prop: 'communityIds',
    type: 'select',
    attrs: { multiple: true, 'collapse-tags': true },
    options: async () => {
      try {
        const params = {
          pageNum: 1,
          pageSize: 1000,
        }
        const res = await $request.post('/api-parking/parking/community/findCommunityList', { params })
        return (res?.rows || []).map((i) => ({ label: i.name, value: i.id }))
      } catch (error) {
        return []
      }
    },
    rules: [{ required: true, message: '请选择所属小区', trigger: 'change' }],
  },
  { label: '简介', prop: 'introduction', type: 'textarea', span: 3 },
  { label: '照片', prop: 'imageUrl', type: 'image', limit: 1, span: 3 },
  { label: '微信附件', prop: 'wxAttachmentUrl', type: 'image', limit: 1, span: 3 },
]
